package map;

public class Map {
	
	public static final Images IMAGES = new Images();
	
	Region[][] regions;
	
	public Map() {
		regions = new Region[4][4];
		for(int x = 0; x < 2; x++) {
			for(int y = 0; y < 2; y++) {
				regions[x][y] = new Region(this, x, y);
			}
		}
	}
	
	public Region[][] getRegions() {
		return regions;
	}
	
	public void setRegions(Region[][] regions) {
		this.regions = regions;
	}
	
	public Region loadRegion(int y, int x) {
		/*if (regions[y][x] == null) {
			return new Region();
		} else {
			return regions[y][x];
		}*/
		return null;
	}
	
	public Region getRegion(int x, int y) {
		return regions[x][y];
	}

	public Region getRegionNorth(int x, int y) {
		return (y+1 == regions[x].length) ? regions[x][0] : regions[x][y+1];
	}

	public Region getRegionSouth(int x, int y) {
		return (y-1 == -1) ? regions[x][regions[x].length-1] : regions[x][y-1];
	}

	public Region getRegionEast(int x, int y) {
		return (x+1 == regions.length) ? regions[0][y] : regions[x+1][y];
	}

	public Region getRegionWest(int x, int y) {
		return (x-1 == -1) ? regions[regions.length-1][y] : regions[x-1][y];
	}

	public Region getRegionNorth(Region region) {
		return (region.getMapY()+1 == regions[region.getMapX()].length) ?
				regions[region.getMapX()][0] :
				regions[region.getMapX()][region.getMapY()+1];
	}

	public Region getRegionSouth(Region region) {
		return (region.getMapY()-1 == -1) ?
				regions[region.getMapX()][regions[region.getMapX()].length-1] :
				regions[region.getMapX()][region.getMapY()-1];
	}

	public Region getRegionEast(Region region) {
		return (region.getMapX()+1 == regions.length) ?
				regions[0][region.getMapY()] :
				regions[region.getMapX()+1][region.getMapY()];
	}

	public Region getRegionWest(Region region) {
		return (region.getMapX()-1 == -1) ?
				regions[regions.length-1][region.getMapY()] :
				regions[region.getMapX()-1][region.getMapY()];
	}
	
}
